package com.video.video.service.impl;

import com.video.common.utils.uuid.IdUtils;
import com.video.video.domain.DClassifyBach;
import com.video.video.domain.app.dto.DClassifyDto;
import com.video.video.domain.app.dto.DGroupingDto;
import com.video.video.domain.vo.ClassifyVo;
import java.util.List;
import com.video.common.utils.DateUtils;
import com.video.video.service.IDGoodsService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.video.video.mapper.DClassifyMapper;
import com.video.video.domain.DClassify;
import com.video.video.service.IDClassifyService;

/**
 * 分类Service业务层处理
 *
 * @author ruoyi
 * @date 2022-09-27
 */
@Service
public class DClassifyServiceImpl implements IDClassifyService
{
    @Autowired
    private DClassifyMapper dClassifyMapper;

    @Autowired
    private IDGoodsService idGoodsService;

    /**
     * 查询分类
     *
     * @param id 分类主键
     * @return 分类
     */
    @Override
    public DClassify selectDClassifyById(String id)
    {
        return dClassifyMapper.selectDClassifyById(id);
    }

    @Override
    public DClassify selectDClassifyByName(String classifyName, int level) {
        return dClassifyMapper.selectDClassifyByName(classifyName,level);
    }

    /**
     * 查询分类列表
     *
     * @param dClassify 分类
     * @return 分类
     */
    @Override
    public List<DClassify> selectDClassifyList(DClassify dClassify)
    {
        return dClassifyMapper.selectDClassifyList(dClassify);
    }

    @Override
    public List<DClassify> selectDClassLevel2List(String pid, String status) {
        return dClassifyMapper.selectDClassLevel2List(pid,status);
    }

    @Override
    public List<DClassifyDto> selectDClassifyDtoList(DClassify dClassify) {
        return dClassifyMapper.selectDClassifyDtoList(dClassify);
    }

    @Override
    public List<ClassifyVo> selectClassifyVoList() {
        return dClassifyMapper.selectClassifyVoList();
    }

    @Override
    public List<ClassifyVo> getlistByPid(String pid) {
        return dClassifyMapper.getlistByPid(pid);
    }

    @Override
    public int updateClassifyStatusBach(DClassifyBach dClassifyBach) {
        return dClassifyMapper.updateDClassifyStatus(dClassifyBach.getId(),dClassifyBach.getStatus());
    }

    /**
     * 新增分类
     *
     * @param dClassify 分类
     * @return 结果
     */
    @Override
    public int insertDClassify(DClassify dClassify)
    {
        dClassify.setId(IdUtils.getId());
        dClassify.setCreateTime(DateUtils.getNowDate());
        return dClassifyMapper.insertDClassify(dClassify);
    }

    /**
     * 修改分类
     *
     * @param dClassify 分类
     * @return 结果
     */
    @Override
    public int updateDClassify(DClassify dClassify)
    {
        dClassify.setUpdateTime(DateUtils.getNowDate());
        return dClassifyMapper.updateDClassify(dClassify);
    }

    /**
     * 批量删除分类
     *
     * @param ids 需要删除的分类主键
     * @return 结果
     */
    @Override
    public int deleteDClassifyByIds(String[] ids)
    {
        int result = dClassifyMapper.deleteDClassifyByIds(ids);
        idGoodsService.deleteDGoodsByCIds(ids);
        return result;
    }

    /**
     * 删除分类信息
     *
     * @param id 分类主键
     * @return 结果
     */
    @Override
    public int deleteDClassifyById(String id)
    {
        return dClassifyMapper.deleteDClassifyById(id);
    }
}
